# -*- coding: utf-8 -*-
# @Time      : 2024/5/16 9:23
# @Author    : 未命名
# @File      : day01
# @Software  : PyCharm

from bs4 import BeautifulSoup
import re
import urllib.request,urllib.error
import xlwt
import sqlite3

def main():
    baseurl = "https://mudanjiang.anjuke.com/sale/p="
    datalist = getDate(baseurl)



def askUrl(url):
    head = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36 Edg/89.0.774.54"
    }
    request = urllib.request.Request(url,headers=head)
    try:
        response = urllib.request.urlopen(request)
        html = response.read().decode("utf-8")
        print(html)  #暂时不用进行打印
    except urllib.error.URLError as e:
        if hasattr(e,'code'):
            print(e.code)
        if hasattr(e,'reason'):
            print(e.reason)
    return html
def getDate(baseurl):
    datalist = []
    for i in range(0,10):
        url = baseurl + str(i)
        html = askUrl(url)
        soup = BeautifulSoup(html,"html.parser")
        for item in soup.find_all('div',class_="house-details"):





if __name__ == "__main__":
    main()
